Skip to main content
Version: 4.2

Introduction

The X-Edge platform loads custom vision algorithms of third-party developers through internal function calls. The platform has functions such as

  • Timing map collection
  • Task scheduling
  • Task management
  • Data interaction.

Calling Method

The X-Edge platform executes vision algorithms defined by third-party developers by calling standard functions. You need to override the algorithm function templates provided by the platform to implement your own algorithm.

  1. Provide the standard algorithm initialization function algorithmInitialization and the algorithm execution main function algorithmDetect.
  2. X-Edge platform uses python scripts to call these two functions.
info

The provided standard functions must be written in python, and the internal execution code can be written in other languages and compiled for python calling.

Vision Algorithm Execution Structure

Module Instruction

Algorithm Initialization (arguments, configs)

This function initializes your algorithms. It will only be executed once when the program starts running to load the algorithm model and auxiliary classes, and register basic parameters.

info

This function has no return parameters, and you are free to define the initialization content.

Input ParameterDescription
arguments
  • Calls initializeArgument(attribute_name, value) to register parameters for all tasks. For example: arguments.initializeArgument('time', 0)
  • The function will create a time parameter for all polling tasks, with an initial value of 0, and store it in the public buffer.
configsA JSON file contains preset input parameters when configuring the algorithm task, converted into a python dict dictionary object in the program. It is a list of dictionaries, and each element in the list is a configuration dictionary for a task.
  • Contains task-related information and some additional configuration parameters required by the algorithm.
  • Task-related information will be automatically loaded by platform components.
  • Does not contain global configuration, and each list element corresponds to a task. If global configuration is required, the same configuration information can be added to each task.

Send, data_map= algorithmDetect(image, timestamp, config, argument)

The algorithmDetect function will be executed when the current task is being called, and the calling process will automatically read the picture, timestamp, configuration, and parameters of the current task and pass them to the function.

  • Input parameters:
ParameterDescription
imageRGB image for identification.
timestampThe host timestamp when the image was acquired.
configThe configuration related to the current task.
  • A dictionary, used to obtain the configuration parameters defined when configuring the task.
  • The additional configuration can be read through the key defined by the developer, and the key and value can be configured on the front end.
argumentParameters related to the current task, including standard parameters, such as the detection area detectArea, and the parameters actively registered during initialization.
  • You can use config.time to directly get the time parameter registered during initialization.
  • It supports adding parameters dynamically. For example, use config.newAttribute = value, a parameter named newAttribute with value value will be automatically created.
  • Return value:
ParameterDescription
sendBoolean, indicating whether to send data currently. If send=True, the communication component will organize the result data and send it to the platform.
data_mapData dictionary, the structure requirements are:
{ 
'tag': string,
'data': list or dict,
'areas':[[top_left_x, top_left_y, bottom_right_x, bottom_right_y],[...]]
}
  • tag: 'alarm': alarm data, 'normal': information data, no alarm is required.
  • data: Data returned by the algorithm. Contact technical support of the platform for returning specific data information. When no additional data, the value is an empty dictionary.
  • areas: Optional field. If this field exists, a rectangular frame will be drawn on the alarm image, and the required format is [[top_left_x, top_left_y, bottom_right_x, bottom_right_y],[...]], currently only supports drawing rectangular frame in red by default.

Algorithm Installation Instructions

After the algorithm is developed, you need to compress and upload it to the platform.

  • For python developers, a requirements.txt file is necessary in the algorithm package, which is convenient for the platform to build an operating environment.
  • For developers of other compilable languages, put the required link libraries and algorithm packages together to prevent problems such as missing libraries. Attach a runtime.json file to the package to describe the running environment. For example:
{ 
'algorithmName': helmet,
'algorithmShowName': helmet algorithm,
'algorithmCode': 3fxda44gf5a3m,
'algorithmDescription': helmet detection algorithm,
'algorithmVersion': 1.0.0,
'algorithmTarget': 2,
'device': 'gpu',
'CUDA_version': '10.2'
}
ParameterDescription
algorithmNameAlgorithm name. required. English lowercase name. Length limit 1~50.
algorithmShowNameAlgorithm display name.
algorithmCodeAlgorithm code, unique identification code. required. Combination of English letters and numbers. Length limit 8~32.
algorithmDescriptionAlgorithm short description.
algorithmVersionCustom algorithm version.
algorithmTargetDetection targets of the algorithm. 0-person, 1-car, 2-other.
deviceSelect form gpu and cpu.
CUDA_versionIf the device is gpu, CUDA version needs to be specified.